#pragma once

#include "Resource.h"

#include "Shader.h"

namespace RenderSystem
{
	class Shader;
	class MaterialManager;
	class MaterialShaderMap;

	class Material
		: public Resource
	{
	public:

		enum EMaterialLightingModel
		{
			MLM_Phong               =0,
			MLM_NonDirectional      =1,
			MLM_Unlit               =2,
			MLM_SHPRT               =3,
			MLM_Custom              =4,
			MLM_Anisotropic         =5,
			MLM_MAX                 =6,
		};
		enum EBlendMode
		{
			BLEND_Opaque            =0,
			BLEND_Masked            =1,
			BLEND_Translucent       =2,
			BLEND_Additive          =3,
			BLEND_Modulate          =4,
			BLEND_MAX               =5,
		};

		Material( const String& strMaterialID, MaterialManager& rMatMgr );
		virtual ~Material(void);

		//Resource interface
		virtual bool Load( const String& strPath );
		virtual bool Unload( void );

		bool IsTransparent( void );
		bool IsShadowCaster( void );
		bool IsReceiveShadows( void );

		void SetShadowCaster( bool bShadowCaster );
		void SetReceiveShadows( bool bReceiveShadows );

		EBlendMode GetBlendMode(void) const;
		EMaterialLightingModel GetLightingModel() const;
		
		virtual bool IsDistorted() const;
		virtual bool IsMasked() const;
		virtual bool IsWireframe() const;
		virtual bool IsTwoSided() const;
		virtual bool IsSpecularAllowed() const;
		virtual bool UsesOneLayerDistortion() const;
		virtual bool IsUsedWithGammaCorrection() const;

		bool InitShaderMap( void );

		virtual bool Compile( const ShaderProfile& rProfile, MaterialShaderMap& rOutMap );

	protected:

		virtual Instance* _CreateInstanceImpl( const String& strInstanceId );

	protected:

		EMaterialLightingModel		m_eLightModel;
		EBlendMode					m_eBlendMode;
		//used to set once per frame among this type of materials
	};
}